<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Floating-Point Precision</title>
<link rel="stylesheet" href="../../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../../index.html" title="Chapter 1. Boost.Convert 2.0">
<link rel="up" href="../formatting_support.html" title="Formatting Support">
<link rel="prev" href="leading_whitespace_characters.html" title="Leading Whitespace Characters">
<link rel="next" href="floating_point_notation.html" title="Floating-Point Notation">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="spirit-nav">
<a accesskey="p" href="leading_whitespace_characters.html"><img src="../../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../formatting_support.html"><img src="../../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../images/home.png" alt="Home"></a><a accesskey="n" href="floating_point_notation.html"><img src="../../../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="boost_convert.converters_detail.charconv_converter.formatting_support.floating_point_precision"></a><a class="link" href="floating_point_precision.html" title="Floating-Point Precision">Floating-Point
          Precision</a>
</h5></div></div></div>
<p>
</p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">cnv</span><span class="special">::</span><span class="identifier">charconv</span> <span class="identifier">cnv</span><span class="special">;</span>

<span class="identifier">BOOST_TEST</span><span class="special">(</span>  <span class="string">"12.3"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">1</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="string">"12.35"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">2</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="string">"12.346"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">3</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>

<span class="identifier">BOOST_TEST</span><span class="special">(</span>  <span class="string">"-12.3"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(-</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">1</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="string">"-12.35"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(-</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">2</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
<span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="string">"-12.346"</span> <span class="special">==</span> <span class="identifier">convert</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;(-</span><span class="number">12.3456</span><span class="special">,</span> <span class="identifier">cnv</span><span class="special">(</span><span class="identifier">arg</span><span class="special">::</span><span class="identifier">precision</span> <span class="special">=</span> <span class="number">3</span><span class="special">)).</span><span class="identifier">value</span><span class="special">());</span>
</pre>
<p>
          </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2009-2022 Vladimir
      Batov<p>
        Distributed under the Boost Software License, Version 1.0. See copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="leading_whitespace_characters.html"><img src="../../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../formatting_support.html"><img src="../../../../images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../images/home.png" alt="Home"></a><a accesskey="n" href="floating_point_notation.html"><img src="../../../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
